// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2024.
* Description: dm functions for vims
*/

#include <linux/module.h>

#include "sd_vims.h"

#define SD_MAX_WS10_BLOCKS_VIMS 0x800U
#define SD_MAX_WS16_BLOCKS_VIMS 0x800U

static int sd_default_support_ws16;
module_param(sd_default_support_ws16, int, 0644);
static bool sd_default_max_ws_blocks_vims;
module_param(sd_default_max_ws_blocks_vims, bool, 0600);

unsigned int sd_max_ws10_blocks(void)
{
	if (sd_default_max_ws_blocks_vims)
		return SD_MAX_WS10_BLOCKS_VIMS;

	return SD_MAX_WS10_BLOCKS;
}
EXPORT_SYMBOL_GPL(sd_max_ws10_blocks);

unsigned int sd_max_ws16_blocks(void)
{
	if (sd_default_max_ws_blocks_vims)
		return SD_MAX_WS16_BLOCKS_VIMS;

	return SD_MAX_WS16_BLOCKS;
}
EXPORT_SYMBOL_GPL(sd_max_ws16_blocks);

void vims_report_sd_write_same(struct scsi_disk *sdkp)
{
	if (sd_default_support_ws16)
		sdkp->ws16 = 1;
}
EXPORT_SYMBOL_GPL(vims_report_sd_write_same);
